package cn.marinda.totipotentwar.global;

import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 配置数据
 *
 * @author hwj
 * @date 2022/01/26
 */
public class ConfigData extends AbstractPluginConfig {
    /**
     * 前缀
     */
    private String prefix;
    private boolean enableTrHologram;
    private boolean bossBar;
    private boolean mysqlEnable;
    //MySQL

    private String host;
    private String port;
    private String userName;
    private String userPassword;
    private String database;
    //location

    private String worldName;
    private double x;
    private double y;
    private double z;

    //game

    private int joinDuration;
    private int maxPlayer;
    private int minPlayer;

    //phase 阶段数据

    private Map<String, Phase> phaseMap = new HashMap<>();

    //结算数据

    private int winPoints;
    private Map<Integer,Rank> rankMap = new HashMap<>();
    //normal消息

    private String title;
    private String subTitle;
    private List<String> resultMessage = new ArrayList<>();
    //bossBar消息

    private String message;
    /**
     * 摘要插件配置
     *
     * @param plugin 配置名称
     */
    public ConfigData(Plugin plugin) {
        super(plugin);
        defaultData();
    }


    /**
     * 初始化数据
     */
    @Override
    public void defaultData(){
        this.prefix = config.getString("prefix");
        this.enableTrHologram = config.getBoolean("enableTrHologram");
        this.bossBar = config.getBoolean("bossBar");
        this.mysqlEnable = config.getBoolean("mysql.enable");
        this.host = config.getString("mysql.host");
        this.port = config.getString("mysql.port");
        this.userName = config.getString("mysql.userName");
        this.userPassword = config.getString("mysql.passWord");
        this.worldName = config.getString("world.name");
        this.x = config.getDouble("world.toLocation.x");
        this.y = config.getDouble("world.toLocation.y");
        this.z = config.getDouble("world.toLocation.z");
        this.joinDuration = config.getInt("game.joinDuration");
        this.maxPlayer = config.getInt("game.maxPlayer");
        this.minPlayer = config.getInt("game.minPlayer");
        ConfigurationSection phase = config.getConfigurationSection("game.phase");
        for(String i : phase.getKeys(false)){
            Phase phase1 = new Phase(config.getString("game.phase." + i + ".weapons"),config.getInt("game.phase." + i + ".points"),config.getDouble("game.phase." + i + ".killPoints"),config.getDouble("game.phase." + i + ".integral"));
            this.phaseMap.put(i,phase1);
        }
        this.winPoints = config.getInt("game.result.winPoints");
        ConfigurationSection result = config.getConfigurationSection("game.result.rank");
        for(int i = 1;i<=result.getKeys(false).size();i++){
            rankMap.put(i,new Rank(config.getString("game.result.rank."+ i + ".title"),config.getString("game.result.rank."+ i + ".subtitle")));
        }
        this.title = config.getString("game.result.normal.title");
        this.subTitle = config.getString("game.result.normal.subtitle");
        this.resultMessage = config.getStringList("game.message");
        this.message = config.getString("game.bossbar.message");
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public boolean isEnableTrHologram() {
        return enableTrHologram;
    }

    public void setEnableTrHologram(boolean enableTrHologram) {
        this.enableTrHologram = enableTrHologram;
    }

    public boolean isBossBar() {
        return bossBar;
    }

    public void setBossBar(boolean bossBar) {
        this.bossBar = bossBar;
    }

    public boolean isMysqlEnable() {
        return mysqlEnable;
    }

    public void setMysqlEnable(boolean mysqlEnable) {
        this.mysqlEnable = mysqlEnable;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getDatabase() {
        return database;
    }

    public void setDatabase(String database) {
        this.database = database;
    }

    public String getWorldName() {
        return worldName;
    }

    public void setWorldName(String worldName) {
        this.worldName = worldName;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getZ() {
        return z;
    }

    public void setZ(double z) {
        this.z = z;
    }

    public int getJoinDuration() {
        return joinDuration;
    }

    public void setJoinDuration(int joinDuration) {
        this.joinDuration = joinDuration;
    }

    public int getMaxPlayer() {
        return maxPlayer;
    }

    public void setMaxPlayer(int maxPlayer) {
        this.maxPlayer = maxPlayer;
    }

    public int getMinPlayer() {
        return minPlayer;
    }

    public void setMinPlayer(int minPlayer) {
        this.minPlayer = minPlayer;
    }

    public Map<String, Phase> getPhaseMap() {
        return phaseMap;
    }

    public void setPhaseMap(Map<String, Phase> phaseMap) {
        this.phaseMap = phaseMap;
    }

    public int getWinPoints() {
        return winPoints;
    }

    public void setWinPoints(int winPoints) {
        this.winPoints = winPoints;
    }

    public Map<Integer, Rank> getRankMap() {
        return rankMap;
    }

    public void setRankMap(Map<Integer, Rank> rankMap) {
        this.rankMap = rankMap;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public List<String> getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(List<String> resultMessage) {
        this.resultMessage = resultMessage;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
